#include <iostream>
#include <future>
#include <unistd.h>

int Add(int x, int y)
{
    std::cout << "init add" << std::endl;
    return x + y;
}

int main()
{
    std::future<int> res = std::async(std::launch::async, Add, 11, 2);
    sleep(1);
    std::cout << "-----------------" << std::endl;
    std::cout << res.get() << std::endl; // 获取异步任务结果，没有则阻塞
    return 0;
}